package com.hxx.day2;

public class TestDemo10 {
    public static void main(String[] args) {

    }
}

/**
 * 懒汉式
 * 自旋锁
 */
class Singleton1{

    private static volatile Singleton1 singleton1;

    private Singleton1(){
    }

    public static synchronized Singleton1 getSingleton(){
        if(singleton1==null){
            singleton1=new Singleton1();
        }
        return singleton1;
    }

    public void show(){
        System.out.println("show方法");
    }
}
